﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddSite.aspx.cs" Inherits="WebApplication1.AddSite" MasterPageFile="~/masterpage/User.Master" %>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">

    <%--Begin Loading ajax section--%>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
                <div class="center">

                    <img alt="" src="images/loading.gif" />
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <%--End Loading ajax section--%>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>

            <div class="container-fluid">


                <div class="control-group col-md-8">
                    <fieldset>
                        <legend>Add Site</legend>
                    </fieldset>
                    <!-- Alert Message -->
                    <asp:Panel ID="divMessage" runat="server" Visible="False" role="alert">
                        <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <asp:Label ID="lblMessage" runat="server" Text="">
                         
                        </asp:Label>
                    </asp:Panel>

                    <label class="control-label">Site Name:</label>
                    <div class="controls">
                        <asp:TextBox ID="txtSiteName" runat="server" class="form-control" MaxLength="199" ToolTip="Site name (max length 199 characters)"></asp:TextBox>
                    </div>


                    <div class="control-group">
                        <label class="control-label"></label>
                        <div class="controls">

                            <asp:Button ID="btnAdd" runat="server" class="btn  btn-primary" Text="Add" OnClick="btnAdd_Click" ToolTip="Click to add new site" />
                        </div>
                    </div>
                    <br />
                    <fieldset>
                        <legend>Site List</legend>
                    </fieldset>

                    <asp:ListView ID="listviewSite" runat="server" DataSourceID="SiteObject" DataKeyNames="id">
                        <AlternatingItemTemplate>
                            <tr style="">
                                <td>
                                    <asp:Label ID="idLabel" runat="server" Text='<%# Eval("id") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' />
                                </td>
                                <td>
                                    <asp:Button ID="DeleteButton" runat="server" class="btn  btn-primary" CommandName="Delete" Text="Delete" />
                                    <asp:Button ID="EditButton" runat="server" class="btn  btn-primary" CommandName="Edit" Text="Edit" />
                                </td>
                            </tr>
                        </AlternatingItemTemplate>
                        <EditItemTemplate>
                            <tr style="">

                                <td>
                                    <asp:Label ID="idLabel" runat="server" Text='<%# Bind("id") %>' />
                                </td>
                                <td>
                                    <asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>' MaxLength="199" ToolTip="Site name" />
                                </td>
                                                                <td>
                                    <asp:Button ID="UpdateButton" runat="server" class="btn  btn-primary" CommandName="Update" Text="Update" />
                                    <asp:Button ID="CancelButton" runat="server" class="btn  btn-primary" CommandName="Cancel" Text="Cancel" />
                                </td>
                            </tr>
                        </EditItemTemplate>
                        <EmptyDataTemplate>
                            <table runat="server" style="">
                                <tr>
                                    <td>No data was returned.</td>
                                </tr>
                            </table>
                        </EmptyDataTemplate>
                        <InsertItemTemplate>
                            <tr style="">
                                <td>
                                    <asp:Button ID="InsertButton" runat="server" class="btn  btn-primary" CommandName="Insert" Text="Insert" />
                                    <asp:Button ID="CancelButton" runat="server" class="btn  btn-primary" CommandName="Cancel" Text="Clear" />
                                </td>
                                <td>
                                    <asp:TextBox ID="idTextBox" runat="server" Text='<%# Bind("id") %>' ToolTip="Id" MaxLength="199" />
                                </td>
                                <td>
                                    <asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>' ToolTip="Site name" MaxLength="199" />
                                </td>
                            </tr>
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <tr style="">
                                <td>
                                    <asp:Label ID="idLabel" runat="server" Text='<%# Eval("id") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' />
                                </td>
                                <td>
                                    <asp:Button ID="DeleteButton" runat="server" class="btn  btn-primary" CommandName="Delete" Text="Delete" />
                                    <asp:Button ID="EditButton" runat="server" class="btn  btn-primary" CommandName="Edit" Text="Edit" />
                                </td>
                            </tr>
                        </ItemTemplate>
                        <LayoutTemplate>
                            <table runat="server" class="table table-bordered">
                                <tr runat="server">
                                    <td runat="server">
                                        <table id="itemPlaceholderContainer" runat="server" border="0" style="" class="table table-hover table-bordered">
                                            <tr runat="server" class="info">
                                                <th runat="server">ID</th>
                                                <th runat="server">Name</th>
                                                <th runat="server">Actions</th>
                                            </tr>
                                            <tr id="itemPlaceholder" runat="server">
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr runat="server">
                                    <td runat="server" style=""></td>
                                </tr>
                            </table>
                        </LayoutTemplate>
                        <SelectedItemTemplate>
                            <tr style="">
                                <td>
                                    <asp:Label ID="idLabel" runat="server" Text='<%# Eval("id") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' />
                                </td>
                                <td>
                                    <asp:Button ID="DeleteButton" runat="server" class="btn  btn-primary" CommandName="Delete" Text="Delete" />
                                    <asp:Button ID="EditButton" runat="server" class="btn  btn-primary" CommandName="Edit" Text="Edit" />
                                </td>
                            </tr>
                        </SelectedItemTemplate>
                    </asp:ListView>

                    <asp:ObjectDataSource ID="SiteObject" runat="server" SelectMethod="GetAllSite" TypeName="Business.SiteManagement" DeleteMethod="DeleteSite" OnDeleted="SiteObject_Deleted" OnUpdated="SiteObject_Updated" UpdateMethod="UpdateSite">
                        <DeleteParameters>
                            <asp:ControlParameter ControlID="listviewSite" Name="id" PropertyName="SelectedValue" Type="Int64" />
                        </DeleteParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="id" Type="Int64" />
                            <asp:Parameter Name="name" Type="String" />
                        </UpdateParameters>
                    </asp:ObjectDataSource>

                </div>

                <div class="control-group col-md-4"></div>

            </div>

        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>


